import constant from '../../../common/constant';
import {
  setData
} from "../../../models/transferData";
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    houseInfo: {
      type: Object,
      value: {}
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    house: {}
  },
  /** 组件的数据监听  */
  observers: {
    houseInfo() {
      let house = this.data.houseInfo
      house.doorModel = `${house.houseRoom}室${house.houseHall}厅 / ${house.houseArea} / ${house.houseDistrict} ${house.houseName}`
      this.setData({
        house
      })
    }
  },

  // 组件的生命周期
  lifetimes: {
    attached: function () {
      getApp().globalData.loginPromise.then(() => {})
    },
    detached: function () {},
  },
  /**
   * 组件的方法列表
   */
  methods: {
    //列表跳转且在url中传值
    onJumpHouseDetail() {
      let t = this
      let {
        house,
      } = t.data
      if (house.isRecommend) {
        wx.gio('track', constant.openHouseDetail, {
          [constant.FromPage]: '合作房源首页',
          [constant.HouseType]: '合作-推荐房源'
        })
      } else {
        wx.gio('track', constant.openHouseDetail, {
          [constant.FromPage]: '合作房源首页',
          [constant.HouseType]: '合作-搜索房源'
        })
      }
      if (house.houseIsMy) {
        setData("isRefreshCooperation", true)
        wx.navigateTo({
          url: `/pages/house/RentalHouseDetail/coopertionHouseInfo/coopertionHouseInfo?cooperationId=${house.houseID}`,
        });
      } else if (house.houseIsCopy) {
        wx.navigateTo({
          url: `/pages/house/RentalHouseDetail/teamworkHouseDetail/teamworkHouseDetail?cooperationId=${house.houseID}`,
        });
      } else {
        wx.navigateTo({
          url: `/pages/house/RentalHouseDetail/teamworkHouseDetail/teamworkHouseDetail?cooperationId=${house.houseID}`,
        });
      }
    },
  }
})